Skip to content

fix: restructure artifacts directory for $ref consumption#2

Closed
hdamker wants to merge 5 commits intomainfrom
fix/restructure-artifacts
Closed

fix: restructure artifacts directory for $ref consumption#2
hdamker wants to merge 5 commits intomainfrom
fix/restructure-artifacts

Conversation

@hdamker
Copy link
Copy Markdown
Owner

@hdamker hdamker commented Mar 25, 2026

What type of PR is this?

  • enhancement/feature

What this PR does / why we need it:

Phase 1 of artifacts directory restructuring (camaraproject/Commonalities#603).

Establishes the common/ and api-templates/ directory structure so that $ref paths in templates are identical to those in API repositories:

  • Moves CAMARA_common.yaml to artifacts/common/CAMARA_common.yaml
  • Adds artifacts/api-templates/sample-service.yaml — a request-response CRUD template demonstrating $ref consumption of common schemas, error responses, parameters, headers, and security schemes
  • Updates documentation references in README.md and CAMARA-API-Design-Guide.md

The sample-service template demonstrates two patterns for error responses:

  • Option A (pure $ref): For responses using only generic error codes — e.g., $ref: "../common/CAMARA_common.yaml#/components/responses/Generic404"
  • Option B (local definition): For responses extending generic errors with API-specific codes — e.g., ResourceNotFound404 with IDENTIFIER_NOT_FOUND alongside generic NOT_FOUND

Prerequisites cherry-picked (will be dropped on rebase after upstream merge):

  • #599 — x-camara-commonalities full version string
  • #602 — comment out placeholders for $ref consumption

Which issue(s) this PR fixes:

Fixes camaraproject#603 (phase 1)

Does this PR introduce a breaking change?

  • Yes
  • No

Special notes for reviewers:

This is a draft PR for early discussion. It will be retargeted to camaraproject/Commonalities after camaraproject#599 and camaraproject#602 merge upstream.

Next steps (phase 2, after #604 merges):

  • Add common/CAMARA_event_common.yaml with CloudEvent/Source/DateTime schemas (OWASP-aligned)
  • Add notification-templates/sample-notification.yaml replacing notification-as-cloud-event.yaml
  • Add event-related API templates (sample-implicit-events.yaml, sample-service-subscriptions.yaml)
  • Migrate camara-cloudevents/ content to new structure

Validation results (0 errors):

Redocly bundle resolves all $ref successfully:

bundling artifacts/api-templates/sample-service.yaml...
📦 Created a bundle for artifacts/api-templates/sample-service.yaml at /tmp/bundled-sample.yaml 20ms.

Spectral lint on bundled output (1 pre-existing warning from CAMARA_common.yaml openId):

 153:12  warning  camara-properties-descriptions  Property description is missing or empty:
         "openId.description" property must be truthy  components.securitySchemes.openId

✖ 1 problem (0 errors, 1 warning, 0 infos, 0 hints)

Spectral also resolves cross-file $ref directly on source files — same result.

Redocly OpenAPI validation:

validating artifacts/api-templates/sample-service.yaml...
artifacts/api-templates/sample-service.yaml: validated in 33ms
Woohoo! Your API description is valid. 🎉

Changelog input

 release-note
fix: restructure artifacts directory — move CAMARA_common.yaml to common/, add sample-service.yaml API template with $ref consumption

Additional documentation

docs
Updated references to CAMARA_common.yaml path in README.md and CAMARA-API-Design-Guide.md

hdamker added 4 commits March 25, 2026 23:24
…roject#598)

With the introduction of release automation, the x-camara-commonalities
field is set automatically and can now use the full version string from
VERSION.yaml instead of just the minor version. Updated the API Design
Guide and artifacts accordingly.
Comment out {{SPECIFIC_CODE}} and {{field}} placeholder patterns in
Generic error responses (400, 403, 404, 409, 422). Commented lines
remain as documentation for API developers. The file becomes directly
consumable via $ref by bundling tools, Spectral, and YAML parsers.

Fixes camaraproject#601
Re-indent 5 commented-out placeholder blocks to match the indentation
of the preceding content line, avoiding false positives from yamllint's
buggy comments-indentation rule.
…ect#603)

Phase 1 of artifacts restructuring:
- Move CAMARA_common.yaml to artifacts/common/ directory
- Add api-templates/sample-service.yaml demonstrating $ref consumption
- Update documentation references to new path

The sample-service template demonstrates two patterns for error responses:
- Option A: pure $ref for responses using only generic error codes
- Option B: local response definition extending generic errors with
  API-specific codes (ResourceNotFound404 example)

Next steps (after camaraproject#604 merges):
- Add CAMARA_event_common.yaml with CloudEvent/Source/DateTime schemas
- Add notification-templates/sample-notification.yaml
- Add event-related API templates (implicit events, subscriptions)
- Migrate camara-cloudevents/ content to new structure
@rartych
Copy link
Copy Markdown

rartych commented Mar 27, 2026

linting_rules folder in artifacts can be removed as linting rules are hosted in tooling - or rather its content replaced with README directing to the right folder in tooling.

@hdamker
Copy link
Copy Markdown
Owner Author

hdamker commented Mar 27, 2026

linting_rules folder in artifacts can be removed as linting rules are hosted in tooling - or rather its content replaced with README directing to the right folder in tooling.

I recommend to do that in a separate PR.

To avoid to keep the directory, I would put the information into the README on artifacts/ level. That might break some personal environments who have checked out the Commonalities repo and using the linting rules locally directly from there ... but it is indeed better to have the rules only in one place.

I'm waiting for the merge of camaraproject#602 to rebase and then create the PR in Commonalities upstream.

@hdamker
Copy link
Copy Markdown
Owner Author

hdamker commented Mar 30, 2026

Closing as there is now camaraproject#606

@hdamker hdamker closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restructure artifacts directory for $ref consumption and bundling

2 participants